Why is const required [C++] ? [closed]

Posted by Andy Leman on Stack Overflow See other posts from Stack Overflow or by Andy Leman
Published on 2010-12-24T02:46:29Z Indexed on 2010/12/24 2:54 UTC
Read the original article Hit count: 156

Filed under:

Possible Duplicate:
What's the difference between a const member function and a non-const member function?

    class Message
{
    public:
        Message(const char* pStr, const char* key);
        Message(const char* pStr);
        Message();

        void encryptMessage();
        void decryptMessage();

        const char* getUnMessage() const;
        const char* getEnMessage() const;

        void getMessage();
        void getKey();

        ~Message();

    private:
        char* pUnMessage;
        char* pEnMessage;
        char* pKey;
};

In this program, why using const? (2 different places) Please explain those 2 for me. Thank you very much!

© Stack Overflow or respective owner

Related posts about c++